﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RaytracerLib.Postprocessing;
using System.ComponentModel;
using RaytracerLib.Resamplers;
using RaytracerLib.Samplers;

namespace Raytracer.PropertyGridDecorators
{
    public abstract class SamplerProperties
    {
        private Sampler m_sampler;

        public SamplerProperties(Sampler a_sampler)
        {
            m_sampler = a_sampler;
        }
    }

    public class UniformSamplerProperties : SamplerProperties
    {
        private UniformSampler m_uniform_sampler;

        public UniformSamplerProperties(UniformSampler a_sampler)
            : base(a_sampler)
        {
            m_uniform_sampler = a_sampler;
        }

        public int Subresolution
        {
            get
            {
                return m_uniform_sampler.Subresolution;
            }
            set
            {
                m_uniform_sampler.Subresolution = value;
            }
        }
    }

    public abstract class NonUniformSamplerProperties : SamplerProperties
    {
        public NonUniformSamplerProperties(NonUniformSampler a_sampler)
            : base(a_sampler)
        {
        }
    }

    public class PoissonSamplerProperties : NonUniformSamplerProperties
    {
        private PoissonSampler m_non_uniform_sampler;

        public PoissonSamplerProperties(PoissonSampler a_sampler)
            : base(a_sampler)
        {
            m_non_uniform_sampler = a_sampler;
        }

        [TypeConverter(typeof(DoubleConverter))]
        public double Density
        {
            get
            {
                return m_non_uniform_sampler.Density;
            }
            set
            {
                m_non_uniform_sampler.Density = value;
            }
        }

        public int Repeats
        {
            get
            {
                return m_non_uniform_sampler.Repeats;
            }
            set
            {
                m_non_uniform_sampler.Repeats = value;
            }
        }
    }

    public abstract class LowDiscrepancySequenceProperties : NonUniformSamplerProperties
    {
        private LowDiscrepancySequenceSampler m_sampler;

        public LowDiscrepancySequenceProperties(LowDiscrepancySequenceSampler a_sampler)
            : base(a_sampler)
        {
            m_sampler = a_sampler;
        }

        public int Subresolution
        {
            get
            {
                return m_sampler.Subresolution;
            }
            set
            {
                m_sampler.Subresolution = value;
            }
        }
    }

    public class HaltonSamplerProperties : LowDiscrepancySequenceProperties
    {
        private HaltonSampler m_halton_sampler;

        public HaltonSamplerProperties(HaltonSampler a_sampler)
            : base(a_sampler)
        {
            m_halton_sampler = a_sampler;
        }

        public int BaseX
        {
            get
            {
                return m_halton_sampler.BaseX;
            }
            set
            {
                m_halton_sampler.BaseX = value;
            }
        }

        public int BaseY
        {
            get
            {
                return m_halton_sampler.BaseY;
            }
            set
            {
                m_halton_sampler.BaseY = value;
            }
        }
    }

    public class HaltonFoldedSamplerProperties : HaltonSamplerProperties
    {
        public HaltonFoldedSamplerProperties(HaltonFoldedSampler a_sampler)
            : base(a_sampler)
        {
        }
    }

    public class HammersleySamplerProperties : LowDiscrepancySequenceProperties
    {
        private HammersleySampler m_hammersley_sampler;

        public HammersleySamplerProperties(HammersleySampler a_sampler)
            : base(a_sampler)
        {
            m_hammersley_sampler = a_sampler;
        }

        public int BaseY
        {
            get
            {
                return m_hammersley_sampler.BaseY;
            }
            set
            {
                m_hammersley_sampler.BaseY = value;
            }
        }
    }

    public class HammersleyFoldedSamplerProperties : HammersleySamplerProperties
    {
        public HammersleyFoldedSamplerProperties(HammersleyFoldedSampler a_sampler)
            : base(a_sampler)
        {
        }
    }

    public class SobolSamplerProperties : LowDiscrepancySequenceProperties
    {
        public SobolSamplerProperties(SobolSampler a_sobol_sampler)
            : base(a_sobol_sampler)
        {
        }
    }
}
